package com.epam.xml.xmlimport;

import java.io.IOException;
import java.util.List;

import javax.xml.parsers.ParserConfigurationException;
import javax.xml.parsers.SAXParserFactory;

import org.apache.log4j.Logger;
import org.apache.log4j.chainsaw.Main;
import org.xml.sax.SAXException;

import com.epam.xml.bank.Client;

public class SAXLauncher {
	private static Logger logger = Logger.getLogger(SAXLauncher.class);

	public static void main(String[] args) {
		try {
			SAXParserFactory factory = SAXParserFactory.newInstance();
			javax.xml.parsers.SAXParser parser;
			parser = factory.newSAXParser();
			SAXParser saxp = new SAXParser();
			parser.parse(Main.class.getClassLoader().getResource("Clients.xml")
						.getFile(), saxp);
			List<Client> clients = saxp.getClients();
			for(Client cl:clients) {
				logger.info(cl.toString());
			}
		} catch (ParserConfigurationException e) {
			logger.error(e);
		} catch (SAXException e) {
			logger.error(e);
		} catch (IOException e) {
			e.printStackTrace();
		}

	}

}
